package apibasej.shared.io;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class UtilExecCmd {

	
	public static void read(InputStream is) throws IOException{
		
		InputStreamReader reader = new InputStreamReader(is);
		BufferedReader leitor = new BufferedReader(reader);
		String linha = null;
		while( (linha = leitor.readLine())!=null ) {
			//processLine(linha);
			System.out.println(linha);
		}
		leitor.close();
		reader.close();
		
	}
	
	public static void exec(String cmd) throws IOException{
		Process p = Runtime.getRuntime().exec(cmd);
		read(p.getInputStream());
		read(p.getErrorStream());
	}
	
	//public abstract void processLine(String line);
	
}
